package java_thinking.unit_10._10_5;

/**
 * @Description : demo在任意的作用域内嵌入一个内部类，在TrackingSlip的作用域之外是不可用的
 * @author: cww
 * @DateTime: 2019-03-10 11:41
 */

public class Parcel6 {
    private void internalTracking(boolean b){
        if (b){
            class TrackingSlip{
                private String id;
                TrackingSlip(String s){
                    System.out.println("TrackingSlip.constructor");
                    id = s;
                }
                String getSlip(){
                    return id;
                }
            }
            TrackingSlip ts = new TrackingSlip("slip");
            String s = ts.getSlip();
        }
        //这里就不能创建该内部类了
//        TrackingSlip trackingSlip = new TrackingSlip();
    }

    public void track(){
        internalTracking(true);
    }

    public static void main(String[] args) {
        Parcel6 parcel6 = new Parcel6();
        parcel6.track();
    }
}
